package cc.site.main.service.impl;

import cc.site.main.bean.TblPet;
import cc.site.main.bean.TblRoom;
import cc.site.main.mapper.TblRoomMapper;
import cc.site.main.service.TblPetService;
import cc.site.main.service.TblRoomService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 房间 服务实现类
 * </p>
 *
 * @author yangruomao
 * @since 2024-04-14
 */
@Service
public class TblRoomServiceImpl extends ServiceImpl<TblRoomMapper, TblRoom> implements TblRoomService {

    @Autowired
    private TblPetService petService;

    @Override
    public int getPetCountByRoomId(Integer roomId) {
        LambdaQueryWrapper<TblPet> qw = new LambdaQueryWrapper<>();
        qw.eq(TblPet::getRoomId,roomId);
        return (int) petService.count(qw);

    }
}
